package com.example.easytts.controller

import com.example.easytts.service.BaiduTranslateService
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/api/translate")
class BaiduTranslateController(
    private val baiduTranslateService: BaiduTranslateService
) {
    data class TranslateRequest(
        val text: String,
        val from: String? = "auto",
        val to: String? = "zh"
    )

    @PostMapping
    fun translate(@RequestBody req: TranslateRequest): Map<String, Any> {
        val result = baiduTranslateService.translate(req.text, req.from ?: "auto", req.to ?: "zh")
        return mapOf("result" to result)
    }
} 